#ifndef _C_MODEL_3D_H_
#define _C_MODEL_3D_H_

#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include <sys/time.h>
#include <unistd.h>
#include <sys/select.h>

#include "view.h"

class CModel3D {
 public:
    CvMat *points3d;
    CvMat *lines;
    CvMat *epilines;
    CvMat *mask_show;
    int npoints;
    CvScalar centroXYZ;
    CView2D *pviews;
    CvMat * angY;
    bool m_alloc;
    int m_nlines;

    CvMat *points2d;

 public:
    
    CModel3D(int nlines)
    {
	m_nlines = nlines;
	m_alloc = false;
	lines=0;
    }

    void calcLinesModel(int nlines=3);

    void alloc(int points);
    void dealloc();
    /* Sort points in top-to-bottom order */
    static int comparex( const void* _a, const void* _b);
    void set_points(int points) { npoints = points;}       

    CvScalar CentreModel();
    int ReadModelFromFile(const std::string filename);
    void SaveModel(CvFileStorage * fs);
    void SaveModel(const std::string filename);
    int deletepoint(int index);
    int addpoint(CvMat *R);
};
#endif
